package cn.qzuie.smart.module.dorm.dal.mysql.dormitories;

import java.util.*;

import cn.qzuie.smart.framework.common.pojo.PageResult;
import cn.qzuie.smart.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.qzuie.smart.framework.mybatis.core.mapper.BaseMapperX;
import cn.qzuie.smart.module.dorm.dal.dataobject.dormitories.DormitoriesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.qzuie.smart.module.dorm.controller.admin.dormitories.vo.*;

/**
 * 宿舍 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DormitoriesMapper extends BaseMapperX<DormitoriesDO> {

    default PageResult<DormitoriesDO> selectPage(DormitoriesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DormitoriesDO>()
                .eqIfPresent(DormitoriesDO::getBuildingId, reqVO.getBuildingId())
                .eqIfPresent(DormitoriesDO::getRoomNo, reqVO.getRoomNo())
                .eqIfPresent(DormitoriesDO::getRoomType, reqVO.getRoomType())
                .eqIfPresent(DormitoriesDO::getPrice, reqVO.getPrice())
                .eqIfPresent(DormitoriesDO::getCurrentOccupancy, reqVO.getCurrentOccupancy())
                .eqIfPresent(DormitoriesDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(DormitoriesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DormitoriesDO::getId));
    }

}